<template>
  <s-table
    bordered
    ref="table"
    :row-key="(record) => record.contract_id"
    :columns="contractColumns"
    :data="contractData"
  >
    <template slot="status_format" slot-scope="text">
      <a-tag>{{text}}</a-tag>
    </template>
    <template slot="action" slot-scope="text,record">
      <a-button size="small" type="primary" @click="toDetail(record.contract_id)">详情</a-button>
    </template>
  </s-table>
</template>

<script>
import { STable } from '@/components'
import { getMemberDetail } from '@/api/member'

export default {
  components: {
    STable
  },
  name: 'MContract',
  data () {
    return {
      contractColumns: [
        {
          title: '合同编号',
          dataIndex: 'contract_no'
        },
        {
          title: '申请主体',
          dataIndex: 'subject'
        },
        {
          title: '总金额',
          dataIndex: 'amount'
        },
        {
          title: '官费',
          dataIndex: 'agency_fee'
        },
        {
          title: '尾款',
          dataIndex: 'tail_money'
        },
        {
          title: '合同状态',
          dataIndex: 'status_format',
          scopedSlots: { customRender: 'status_format' }
        },
        {
          title: '创建时间',
          dataIndex: 'created_at'
        },
        {
          title: '操作',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        }
      ],
      contractData: parameters => {
        return getMemberDetail(Object.assign(parameters, this.queryParam)).then(res => {
          return res.result
        })
      },
      queryParam: {}
    }
  },
  created () {
    this.queryParam['uid'] = this.$route.params.id
    this.queryParam['type'] = 2
  },
  methods: {
    toDetail (id) {
      this.$router.push({ name: 'ContractDetail', params: { id: id } })
    }
  }
}
</script>

<style scoped>

</style>
